//
//  HWRequestLogManage
//
//  Created by 李含文 on 2021/4/28.
//  Copyright © 2021 MINISO. All rights reserved.
//

#import <Foundation/Foundation.h>

#define k_HWLogViewModel_DataUpdate @"k_HWLogViewModel_DataUpdate"
 
/* 回主线程操作 */
static inline void hwlog_dispatch_main_queue(void(^ _Nullable block)(void)) {
    if (!block) return;
    if (dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL) == dispatch_queue_get_label(dispatch_get_main_queue()))
        block();
    else
        dispatch_async(dispatch_get_main_queue(), block);
}

NS_ASSUME_NONNULL_BEGIN

@interface HWLogModel : NSObject
/// code
@property (nonatomic, assign) NSInteger code;
/// url
@property (nonatomic, copy) NSString *url;
/// 请求头
@property (nonatomic, copy) NSString *header;
/// 请求参数
@property (nonatomic, copy) NSString *body;
/// 返回内容
@property (nonatomic, copy) NSString *content;
/// 任务
@property (nonatomic, copy) NSURLRequest *request;
/// 请求方式
@property (nonatomic, copy) NSString *HTTPMethod;
/// 响应体
@property (nonatomic, strong) id responseObject;
/// 错误信息
@property (nonatomic, strong) NSError *error;
/// 请求时间
@property (nonatomic, copy) NSString *timeString;
/// 开始时间戳
@property (nonatomic, assign) NSTimeInterval starttime;
/// 结束时间戳
@property (nonatomic, assign) NSTimeInterval endtime;
/// 请求时的显示的控制器名称
@property (nonatomic, strong) NSString *vcName;
/// 请求时的显示的控制器Title
@property (nonatomic, strong) NSString *vctitle;



/// cell高度
@property (nonatomic, assign) CGFloat cellH;

- (CGFloat)getCellH;
@end

@interface HWLogViewModel : NSObject

+ (HWLogViewModel *)shared;

/// <#name#>
@property (nonatomic, strong) NSMutableArray<HWLogModel *> *models;

- (void)addstart_time:(NSString *)start_time
           end_time:(NSString *)end_time
              vc_nmae:(NSString *)vc_nmae
             vc_title:(NSString *)vc_title
          status_code:(NSString *)status_code
              request:(NSURLRequest *)request
       responseObject:(id)responseObject error:(NSError * __nullable)error;

- (void)cleanData;

@end

NS_ASSUME_NONNULL_END
